<template>
  <div>
    <el-dialog title="批量添加" :visible.sync="open">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="客户姓名" prop="name">
          <file-upload ref="fileUpload"
                       :limit="1"
                       :fileSize="5"
                       :fileType="['xlsx']"
                       @input="handleInput"
          ></file-upload>
<!--          上传成功会触发input事件-->
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="open=false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import FileUpload from '@/components/FileUpload'
import {uploadClues} from '@/api/crm/clue'
export default {
  name: "batch-add",
  data(){
    return{
      open:false,
      form:{
        //文件名字
        filename:null,
      },
      components:{FileUpload},
    }
  },
  methods:{
    handleInput(filenames){
      this.form.filename=filenames
    },
    submitForm(){
      uploadClues(this.form).then(()=>{
        this.$modal.msgSuccess("操作成功")
        this.open=false
        this.$emit("success")
      })
    },
    resetForm(){
      this.form={
        filename: null,
      }
    }
  }
}
</script>

<style scoped>

</style>
